# Which compiler
CC = gcc
AR = ar
AT = @

# Option for development
CFLAGS = -g -O2 -Wall
# Option for release
# CFLAGS = -O -Wall

LIBS := -lm
LIBS += -lpthread

OUTPUT = exec

MIDDLEWARE_PATH = ../..

# source file
SRCS := main.c
SRCS += ../kv.c
SRCS += kv_adapter.c
SRCS += ${MIDDLEWARE_PATH}/dymem/dymem.c
SRCS += ${MIDDLEWARE_PATH}/dymem/linux/dymem_adapter.c

OBJS = $(SRCS:.c = .o)

# Where are include files kept
CFLAGS := -I./
CFLAGS += -I../
CFLAGS += -I${MIDDLEWARE_PATH}
CFLAGS += -I${MIDDLEWARE_PATH}/dymem
CFLAGS += -I${MIDDLEWARE_PATH}/dymem/linux

CFLAGS += -DDYMEM_DEBUG_ENABLE
CFLAGS += -DDYMEM_ASSERT_ENABLE


all: $(OUTPUT)
	$(AT)echo "build done"

$(OUTPUT): $(OBJS)
	$(AT)$(CC) $^ -o $@ $(CFLAGS) $(LIBS)

%.o: %.c
	$(AT)$(CC) -c $< $(CFLAGS)

.PHONY: clean
clean:
	$(AT)-rm -rf $(OUTPUT) *.o $(LUA_SRCS_PATH)/*.o

